package ch06;
class Product {
	static int count = 0;
	int serialNo;

	{
		serialNo = ++count;
	}

	public Product() {}
}

class _22_ProductTest {
	public static void main(String args[]) {
		Product p1 = new Product();
		Product p2 = new Product();
		Product p3 = new Product();

		System.out.println("p1 serial no: " + p1.serialNo);
		System.out.println("p2 serial no: " + p2.serialNo);
		System.out.println("p3 serial no: " + p3.serialNo);
		System.out.println("the number of pieces: " + Product.count);  
	}
}
/*
p1 serial no: 1
p2 serial no: 2
p3 serial no: 3
the number of pieces: 3
*/